package gwtool.gui.dataSetTable.cellRenderer;

import gwtool.container.PruefungAnzeigen;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

public class PruefungCellRenderer implements TableCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 
	 */
	private TableCellRenderer renderer;

	public PruefungCellRenderer(TableCellRenderer renderer) {
		this.renderer = renderer;
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object o, boolean isSelected, boolean hasFocus, int row,
			int column) {

		PruefungAnzeigen p = (PruefungAnzeigen) o;
		Component c = renderer.getTableCellRendererComponent(table, o, isSelected,

		hasFocus, row, column);
		if (!p.toString().equals("")) {
			if (p.pruefungFaellig()) {
				c.setForeground(Color.RED);
			} else if (p.pruefungFaelligInTagen(30)) {
				c.setForeground(Color.ORANGE);
			} else {
				c.setForeground(Color.BLACK);
			}
		}
		((JComponent) c).setToolTipText(p.getPruefungsName() + "  " + p.toString());
		return c;
	}
}
